@echo off
echo Starting optimized build deployment...

REM Step 1: Delete old files
echo Deleting old files...
if exist "..\options.html" del "..\options.html" /Q
if exist "..\popup.html" del "..\popup.html" /Q
if exist "..\libs" rmdir "..\libs" /S /Q
echo Old files deleted!

REM Step 2: Copy new build artifacts
echo Copying new build files...

REM Copy dist/libs directory to root
if exist ".\dist\libs" (
    xcopy ".\dist\libs" "..\libs" /E /I /Y
    echo libs directory copied!
) else (
    echo Warning: dist/libs directory not found!
)

REM Copy HTML files from dist/public to root
if exist ".\dist\public\options.html" (
    copy ".\dist\public\options.html" "..\options.html" /Y
    echo options.html copied!
) else (
    echo Warning: dist/public/options.html file not found!
)

if exist ".\dist\public\popup.html" (
    copy ".\dist\public\popup.html" "..\popup.html" /Y
    echo popup.html copied!
) else (
    echo Warning: dist/public/popup.html file not found!
)

echo All files deployed successfully!